<template>
  <d2-container>
    <div class="d2-breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>报备管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-form :inline="true" class="SearchForm" label-width="110px">
      <el-row :gutter="20">
        <el-col :span="7">
          <el-form-item label="报备单号">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.orderNo"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="企业名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.customerCompany"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="园区">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.gardenName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="房源名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.housingName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="带看经纪人名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.agentName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="报备状态">
            <el-select
              v-model="searchForm.lookHousingStatus"
              placeholder="请选择"
              style="width:207px"
            >
              <el-option label="等待看房" :value="1"></el-option>
              <el-option label="看房结束" :value="2"></el-option>
              <el-option label="发放佣金" :value="3"></el-option>
              <el-option label="报备失败" :value="4"></el-option>
              <el-option label="看房超时" :value="5"></el-option>
              <el-option label="等待确认" :value="6"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-button type="primary" @click="search()" icon="el-icon-search" style="margin:10px"
            >查询</el-button
          >
          <el-button type="danger" icon="el-icon-refresh" @click="reset" style="margin:10px"
            >重置</el-button
          >
        </el-col>
      </el-row>
    </el-form>

    <el-table border :data="tableData.list">
      <el-table-column label="ID" align="center" prop="id"></el-table-column>
      <el-table-column
        label="报备单号"
        align="center"
        prop="orderNo"
      ></el-table-column>
      <el-table-column
        label="企业名称"
        align="center"
        prop="customerCompany"
      ></el-table-column>
      <el-table-column
        label="企业联系人"
        align="center"
        prop="customerName"
      ></el-table-column>
      <el-table-column
        label="企业联系方式"
        align="center"
        prop="customerMobile"
      ></el-table-column>
      <el-table-column
        label="园区"
        align="center"
        prop="gardenName"
      ></el-table-column>
      <el-table-column
        label="房源名称"
        align="center"
        prop="housingName"
      ></el-table-column>
      <el-table-column
        label="房东名称"
        align="center"
        prop="masterName"
      ></el-table-column>
      <el-table-column
        label="房源经纪人名称"
        align="center"
        prop="houseAgentName"
      ></el-table-column>
      <el-table-column
        label="房源经纪人联系方式"
        align="center"
        prop="houseAgentPhone"
      ></el-table-column>
      <el-table-column
        label="带看经纪人名称"
        align="center"
        prop="agentName"
      ></el-table-column>
      <el-table-column
        label="带看经纪人联系方式"
        align="center"
        prop="agentPhone"
      ></el-table-column>
      <el-table-column label="报备状态" align="center" prop="lookHousingStatus">
        <template slot-scope="scope">
          {{
            [
              "审核中",
              "等待看房",
              "看房结束",
              "发放佣金",
              "报备失败",
              "看房超时",
              "等待确认",
            ][scope.row.lookHousingStatus]
          }}
        </template>
      </el-table-column>
      <el-table-column label="开始看房时间" align="center" prop="beginTime">
        <template slot-scope="scope">
          {{ $moment(scope.row.beginTime).format("YYYY-MM-DD hh:mm:ss") }}
        </template>
      </el-table-column>
      <el-table-column label="看房结束时间" align="center" prop="endTime">
        <template slot-scope="scope">
          {{ $moment(scope.row.endTime).format("YYYY-MM-DD hh:mm:ss") }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="scope">
          <router-link :to="`/report/detail/${scope.row.id}`">
            <el-button type="text">查看</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="search"
      @current-change="search"
      :current-page.sync="page"
      :page-sizes="[10, 25, 50, 100]"
      :page-size.sync="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.total"
    ></el-pagination>
  </d2-container>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      searchForm: {},
      tableData: {
        list: [],
        total: 0,
      },
      page: 1,
      pageSize: 10,
      rules: {},
    };
  },
  methods: {
    search() {
      let params = {
        pageNum: this.page,
        pageSize: this.pageSize,
        ...this.searchForm,
      };

      this.$axios.post("/wxLookHousingOrder/list", params).then((result) => {
        if (result) {
          this.tableData = {
            list: result.data.list,
            total: result.data.total,
          };
        } else {
          this.$message.error(result.data.msg);
        }
      });
    },
    reset() {
      this.searchForm = {};
      this.search();
    },
    deleteInfo(id) {
      const _this = this;
      this.$confirm("确定删除该条数据？", "确认删除", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        closeOnPressEscape: false,
        closeOnClickModal: false,
      }).then(() => {
        let params = {
          _id: id,
        };
        _this.$axios.post("/admin/deleteNote", params).then((res) => {
          if (res) {
            _this.$message({
              message: res.data.msg,
              type: "error",
            });
          } else {
            _this.$message({
              message: "删除成功",
              type: "success",
            });
            _this.search();
          }
        });
      });
    },
  },
  created() {
    this.search();
  },
};
</script>

<style scoped lang="scss">
</style>
